// 文章编辑页面样式
@use '../variables' as *;

.post-edit {
  padding: 24px;
  background: #f8f9fa;
  min-height: calc(100vh - 64px);
}

// 示例数据提示样式
.sample-data-notice {
  margin-bottom: 16px;
  
  .el-alert__title {
    font-weight: 600;
  }
  
  .el-alert__description {
    font-size: 14px;
    line-height: 1.5;
  }
}

// 页面头部
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  padding: 24px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);

  .header-left {
    .page-title {
      margin: 0 0 8px 0;
      font-size: 1.8rem;
      font-weight: 600;
      color: $text-primary;
    }

    .page-subtitle {
      margin: 0;
      color: $text-secondary;
      font-size: 14px;
    }
  }

  .header-actions {
    display: flex;
    gap: 12px;
  }
}

// 主要内容区域
.edit-content {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  align-items: start;

  @media (max-width: 1200px) {
    grid-template-columns: 1fr;
  }
}

// 左侧编辑区域
.edit-main {
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  overflow: hidden;

  .form-section {
    padding: 24px;
    border-bottom: 1px solid #f0f0f0;

    &:last-child {
      border-bottom: none;
    }

    .section-label {
      display: block;
      margin-bottom: 12px;
      font-weight: 600;
      color: $text-primary;
      font-size: 16px;
    }

    .title-input {
      :deep(.el-input__wrapper) {
        font-size: 18px;
        font-weight: 500;
      }
    }
  }
}

// Markdown 编辑器
.markdown-editor {
  .editor-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;

    .el-button-group {
      .el-button {
        padding: 8px 12px;
        border-radius: 6px;
        margin-right: 4px;
        
        &:hover {
          background: rgba($primary-color, 0.1);
          color: $primary-color;
        }
      }
    }

    .editor-actions {
      .el-switch {
        --el-switch-on-color: $primary-color;
      }
    }
  }

  .editor-content {
    .markdown-input {
      .content-textarea {
        :deep(.el-textarea__inner) {
          font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
          font-size: 14px;
          line-height: 1.6;
          border: none;
          resize: vertical;
          min-height: 400px;
          
          &:focus {
            box-shadow: none;
            border: none;
          }
        }
      }
    }

    .markdown-preview {
      padding: 24px;
      min-height: 400px;
      background: white;

      .preview-content {
        line-height: 1.8;
        color: $text-primary;

        h1, h2, h3, h4, h5, h6 {
          margin: 24px 0 16px 0;
          font-weight: 600;
          color: $text-primary;
        }

        h1 { font-size: 2rem; }
        h2 { font-size: 1.5rem; }
        h3 { font-size: 1.25rem; }
        h4 { font-size: 1.125rem; }

        p {
          margin: 0 0 16px 0;
          line-height: 1.8;
        }

        ul, ol {
          margin: 16px 0;
          padding-left: 24px;
        }

        li {
          margin: 8px 0;
        }

        blockquote {
          margin: 16px 0;
          padding: 12px 16px;
          border-left: 4px solid $primary-color;
          background: rgba($primary-color, 0.05);
          color: $text-secondary;
        }

        code {
          background: #f1f3f4;
          padding: 2px 6px;
          border-radius: 4px;
          font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
          font-size: 0.9em;
        }

        pre {
          background: #f8f9fa;
          padding: 16px;
          border-radius: 8px;
          overflow-x: auto;
          margin: 16px 0;

          code {
            background: none;
            padding: 0;
            color: $text-primary;
          }
        }

        a {
          color: $primary-color;
          text-decoration: none;
          
          &:hover {
            text-decoration: underline;
          }
        }

        img {
          max-width: 100%;
          height: auto;
          border-radius: 8px;
          margin: 16px 0;
        }

        table {
          width: 100%;
          border-collapse: collapse;
          margin: 16px 0;

          th, td {
            padding: 12px;
            border: 1px solid #e9ecef;
            text-align: left;
          }

          th {
            background: #f8f9fa;
            font-weight: 600;
          }
        }
      }
    }
  }
}

// 右侧设置面板
.edit-sidebar {
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  position: sticky;
  top: 24px;

  .sidebar-section {
    padding: 24px;
    border-bottom: 1px solid #f0f0f0;

    &:last-child {
      border-bottom: none;
    }

    .section-title {
      margin: 0 0 20px 0;
      font-size: 16px;
      font-weight: 600;
      color: $text-primary;
    }

    .form-item {
      margin-bottom: 20px;

      &:last-child {
        margin-bottom: 0;
      }

      .form-label {
        display: block;
        margin-bottom: 8px;
        font-weight: 500;
        color: $text-primary;
        font-size: 14px;
      }

      .el-select,
      .el-date-picker,
      .el-input {
        width: 100%;
      }
    }
  }
}

// 封面图片上传
.cover-upload {
  .cover-uploader {
    display: flex;
    justify-content: center;
    align-items: center;
    
    .el-upload {
      border: 2px dashed #d9d9d9;
      border-radius: 8px;
      cursor: pointer;
      position: relative;
      overflow: hidden;
      transition: border-color 0.3s;
      width: 150px;
      height: 150px;

      &:hover {
        border-color: $primary-color;
        
        .cover-uploader-icon {
          color: $primary-color;
          transform: scale(1.1);
        }
      }

             .cover-uploader-icon {
         font-size: 48px;
         color: #8c939d;
         width: 100%;
         height: 150px;
         line-height: 150px;
         text-align: center;
         transition: all 0.3s ease;
         display: flex;
         align-items: center;
         justify-content: center;
       }

       .cover-image {
         width: 100%;
         height: 150px;
         object-fit: cover;
         border-radius: 6px;
       }
    }
  }

  .upload-tip {
    margin: 12px 0 0 0;
    font-size: 12px;
    color: $text-secondary;
    text-align: center;
  }
}

// 响应式设计
@media (max-width: 1200px) {
  .edit-content {
    grid-template-columns: 1fr;
  }

  .edit-sidebar {
    position: static;
  }
}

@media (max-width: 768px) {
  .post-edit {
    padding: 16px;
  }

  .page-header {
    flex-direction: column;
    gap: 16px;
    align-items: stretch;

    .header-actions {
      justify-content: flex-end;
    }
  }

  .edit-main,
  .edit-sidebar {
    .form-section,
    .sidebar-section {
      padding: 16px;
    }
  }

  .markdown-editor {
    .editor-toolbar {
      flex-direction: column;
      gap: 12px;
      align-items: stretch;

      .el-button-group {
        justify-content: center;
        flex-wrap: wrap;
      }
    }
  }
}

@media (max-width: 480px) {
  .post-edit {
    padding: 12px;
  }

  .page-header {
    padding: 16px;

    .page-title {
      font-size: 1.5rem;
    }
  }

  .edit-main,
  .edit-sidebar {
    .form-section,
    .sidebar-section {
      padding: 12px;
    }
  }
} 